home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-08-22 | 2.2 KB | 78 lines | [TEXT/GEOL] |
- Item 6277888 18-July-89 18:58
-
- From: ARBOGAST Peat Marwick, Chris Arbogast
-
- To: ROSENSTEIN1 Rosenstein, Larry
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: re to re MPW Pascal bug
-
- Larry,
-
- I would like to disagree. You may be correct that this is not considered a
- bug in the compiler. If that is so then I would argue that it is a bug in the
- language definition.
-
- Using the same example…
-
- PROCEDURE Test;
- VAR aFoo: TFoo;
- aFoo2: TFoo;
- BEGIN
- aFoo2 := TFoo(aFoo);
- END;
-
- >In this case, you are casting aFoo even though it hasn't been initialized yet.
- >When debugging is turned on, a cast involving an object reference generates
- >code that checks the cast's validity.
-
- This check is unwarrented. If that's what I want to do why can't I do it?
- At most I would expect a warning. The case of new is just one example. If my
- first use of an unitialized variable is initializing through the use of a VAR
- parameter like in the case of NEW(), why should I be prevented from doing this?
-
- A similar problem arises when one tries to use the Member() function.
- MacApp gets in the way by checking object disipline before calling member().
- This force the programmer to test for nil explicitly even though member() would
- ordinarily handle that case by returning false.
-
- ie., one must write
- IF (aView <> Nil) & (member( aView, TMyView )) THEN …
-
- rather then just
- IF member( aView, TMyView ) THEN …
-
- Why should a cast do any checking at all? Often, the reason to the cast is
- being used in the first place is to avoid the type or range checking that would
- otherwise occur.
-
- I was amazed to find that the compiler actually generates different code
- depending on the way the cast is used. For example
-
- VAR
- aFoo : TFoo;
- aBar : TBar;
-
- Begin
- aFoo := some.valid.foo;
-
- IF case1 THEN
- aBar := TBar( aFoo ) { case1 works fine }
- ELSE
- TFoo( aBar ) := aFoo; { this case does not }
-
- End;
-
- Maybe I am off the wall but it seems that both of these cases should
- generate the same code. Just a MOVE.L instruction that copies aFoo into aBar.
-
- Any comments?
-
- Chris Arbogast
- Peat Marwick Main & Co.
-
-
-
-
-